﻿using Inaction.Host;
using Inaction.ServiceProxy;
using System;
using System.Security.Principal;
using System.ServiceModel;

namespace Inaction.Service.Hosts
{
    [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerCall, MaxItemsInObjectGraph = int.MaxValue)]
    public class WcfService : IHost
    {

        #region 构造
        public WcfService()
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledException);
        }

        void UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var exception = (System.Exception)(e.ExceptionObject);
            Inaction.Util.Loger.WriteLog(exception);
        }
        #endregion

        #region IHost 成员
        public Response Login(Request request)
        {
            return HostHelper.Login(request);
        }

        public Response Query(Request request)
        {
            return HostHelper.Query(request);
        }

        public Response Save(Request request)
        {
            return HostHelper.Save(request);
        }

        public Response Excute(Request request)
        {
            return HostHelper.Excute(request);
        }

        public Response Invoke(Request request)
        {
            return HostHelper.Invoke(request);
        }
        #endregion
    }
}